#include "Joint.h"

Joint::Joint(BodyLink *_bIn, BodyLink *_bOut){
	mModelID=-1;
	mBodyIn=_bIn;
	mBodyOut=_bOut;
	if(mBodyIn != NULL)
		mBodyIn->addChildJoint(this);
	if(mBodyOut != NULL)
		mBodyOut->setParentJoint(this);
}

void Joint::addDof(Dof *d){
	mDofs.push_back(d);
	d->setJoint(this);
}

void Joint::addTransform(Transformation *t, bool _isVariable){
	t->setJoint(this);
	t->setVariable(_isVariable);
	mTransforms.push_back(t);
	if(_isVariable) {	// add dofs of variable transform only
		for(int i=0; i<t->getNumDofs(); i++){
			addDof(t->getDof(i));
		}
	}
}
